import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Objects;
import java.util.Queue;

/**
 * @author CoderXshuai
 * @date 2021/9/2 21:45
 */
public class ActualStroke {
    static int[] dx = {1, -1, 0, 0, 0, 0};
    static int[] dy = {0, 0, 1, -1, 0, 0};
    static int[] dz = {0, 0, 0, 0, 1, -1};
    static int[][][] total;
    static int vol = 0;
    static int m;
    static int n;
    static int l;
    static int t;

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] s = reader.readLine().split(" ");
        m = Integer.parseInt(s[0]);
        n = Integer.parseInt(s[1]);
        l = Integer.parseInt(s[2]);
        t = Integer.parseInt(s[3]);
        total = new int[l][m][n];
        for (int i = 0; i < l; i++) {
            for (int j = 0; j < m; j++) {
                String[] s1 = reader.readLine().split(" ");
                for (int k = 0; k < n; k++) {
                    total[i][j][k] = Integer.parseInt(s1[k]);
                }
            }
        }
        for (int i = 0; i < l; i++) {
            for (int j = 0; j < m; j++) {
                for (int k = 0; k < n; k++) {
                    if (total[i][j][k] == 1) {
                        bfs(i, j, k);
                    }
                }
            }
        }
        System.out.print(vol);
        reader.close();
    }

    static void bfs(int x, int y, int z) {
        Queue<Data> q = new LinkedList<>();
        q.offer(new Data(x, y, z));
        total[x][y][z] = 0;
        int temp = 1;
        while (!q.isEmpty()) {
            Data cur = q.poll();
            for (int j = 0; j < 6; j++) {
                int nx = cur.x + dx[j];
                int ny = cur.y + dy[j];
                int nz = cur.z + dz[j];
                if ((nx >= 0 && nx < l) && (ny >= 0 && ny < m) && (nz >= 0 && nz < n) && total[nx][ny][nz] == 1) {
                    temp++;
                    total[nx][ny][nz] = 0;
                    q.offer(new Data(nx, ny, nz));
                }
            }
        }
        if (temp >= t) {
            vol += temp;
        }
    }

    static class Data {
        int x;
        int y;
        int z;

        public Data(int x, int y, int z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Data)) return false;
            Data data = (Data) o;
            return x == data.x && y == data.y && z == data.z;
        }

        @Override
        public int hashCode() {
            return Objects.hash(x, y, z);
        }
    }
}
